Object Storage GitHub Actions 연동 트러블슈팅 가이드

AWS CLI Object Storage 업로드 문제 해결 가이드

발생 문제

시도한 해결 방법

  1. AWS CLI 설정 조정

    • multipart_threshold 값 조정 시도
    • 다양한 AWS CLI 설정 변경 시도
    • 결과: 동일한 오류 지속
  2. AWS SDK (Node.js) 사용

    const client = new S3Client({
      endpoint: 'https://storage-endpoint.example.com:443',
      credentials: {
        accessKeyId: '${{ secrets.STORAGE_ACCESS_KEY }}',
        secretAccessKey: '${{ secrets.STORAGE_SECRET_KEY }}'
      },
      region: '${{ secrets.STORAGE_REGION }}',
      forcePathStyle: true
    });
    
    • SDK 설정에서 forcePathStyle: true 추가
    • 체크섬 모드 비활성화
    • 결과: SSL 인증서 검증 문제 발생
  3. 폴더 구조 관련 추가 설정

    async function uploadFiles(dir) {
      const files = await fs.readdir(dir, { recursive: true });
      for (const file of files) {
        if ((await fs.stat(file)).isFile()) {
          await client.send(new PutObjectCommand({
            Bucket: bucketName,
            Key: file,
            Body: await fs.readFile(file),
            ContentType: mime.getType(file) || 'application/octet-stream'
          }));
        }
      }
    }
    
    • recursive 옵션으로 하위 폴더 탐색
    • ContentType 설정 필요
    • 파일 경로 유지를 위한 추가 처리 필요

최종 해결 방법

GitHub Actions Workflow 설정

name: Deploy to Storage

on:
  push:
    branches: [ main ]

jobs:
  deploy:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v3
    
    # AWS CLI 2.9 버전 설치
    - name: Install specific version of AWS CLI
      run: |
        curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.9.0.zip" -o "awscliv2.zip"
        unzip awscliv2.zip
        sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update
        
    # AWS Credentials 설정
    - name: Configure AWS Credentials
      run: |
        aws configure set aws_access_key_id ${{ secrets.STORAGE_ACCESS_KEY }}
        aws configure set aws_secret_access_key ${{ secrets.STORAGE_SECRET_KEY }}
        aws configure set region ${{ secrets.STORAGE_REGION }}
        aws configure set output json
        
    # Object Storage에 파일 업로드
    - name: Upload to Storage
      run: |
        aws --endpoint-url=${{ secrets.STORAGE_URL }} s3 sync ./dist s3://${{ secrets.STORAGE_BUCKET }} --delete

환경 변수 설정 필요사항

STORAGE_ACCESS_KEY: 스토리지 액세스 키
STORAGE_SECRET_KEY: 스토리지 시크릿 키
STORAGE_REGION: 리전 정보
STORAGE_URL: 스토리지 엔드포인트 URL (예: https://storage-endpoint.example.com:443)
STORAGE_BUCKET: 버킷 이름

주요 해결 포인트

체크 사항

참고 사항

한계점

해결방안의 장점